Trigger (help needed)

Hello,

 

I'm trying to write a trigger the would find the correct baseline module within the BaselineSet under review(*.ini). I was wondering is there a way that the focus can be put on the module window of the open baseline rather than the Database explorer? Do you see any improves I should make/are there any mistakes within my code I should address? Thank you

 

? for Dynamic Trigger - Once deployed is there a way of deleting them without closing down the DOORS client? I can parse the triggers in the Database but how do you know it the correct Trigger for deletion "name(t) gives e.g. dynamic 1"


EHcnck - Fri Sep 19 09:02:16 EDT 2014

Re: Trigger (help needed)
BobSherman - Sun Aug 23 10:48:37 EDT 2015

Did  you ever get an answer to the question about deleting dynamic triggers.   If I understand the question correctly... I have the same problem... i.e. there does not appear to be a way to control the "name" of dynamic triggers.  The idea would be to control the "names" of dynamic triggers in a way that makes it easy to find them later (for deletion).  Would you please share how you solved this problem?

Regards,

Bob Sherman

Re: Trigger (help needed)
pommCannelle - Wed Aug 26 08:26:04 EDT 2015

Hi ! 

The trigger deletion (management ...) is not so hard ;)
Here after an example to add/remove a trigger from a module ... 

Trigger t = null
DBE l = null

// function activated by trigger
void trig_activation(Trigger t){
    Object o = object(t)
    if (null o) return
    set( l, "Object " o."absolute number""" )
}

// add a gui to manage the trigger
void install_trigger(DB x){
    t = trigger(project->module->"/ESPACE TEST DOORS/pommCannelle/essai 2"->object, sync, 5, trig_activation)
    if ( null t ) set(l, "FAIL to actrivate the trigger")
    else set(l, "trigger activation OK")
}

void delete_trigger(DB x){
    if (null t) return
    string errmess = delete t
    if ( ! null errmess ) set(l, errmess "")
    else set(l, "Trigger deletion OK")
}

void do_close(DB x){
    if ( ! null t ) delete_trigger(null) 
    hide x; destroy x
}

// build the gui
DB test = create "do what you want in dxl..."
l = label(test, "")
apply(test, "Add trigger", install_trigger)
apply(test, "Remove trigger", delete_trigger)
close (test, false, do_close)

realize(test){
    setSize(test, 300, 110)
}

show test

Well ... regarding your concern, i have to admit this code is unfair ;)
The fact is that the DB context stores the trigger to deal with via the t variable. 
Fortunately, we can use the doors structure to have a global variable able to store what we need.
2 little things to do ...
- Add a dxl in the directory "
IBM\Rational\DOORS\your doors version\lib\dxl\startupFiles" and declare a Skip variable as todo list ->Skip todo_list = createString().
- Add a dxl in the directory "IBM\Rational\DOORS\your doors version\lib\dxl\finishfiles" and clean the memory -> delete todo_list. (Yes ... to be clean is important ... really ! ;) )

Now we have a structure to store our dynamic trigger !
So when you create your trigger, add his deletion in your todo list -> add(todo_list, "delete this dynamic trigger", t) ... 
And when you need it, just loop on your todo list, get the trigger back and then delete it !
Enjoy !!